Skip to content

Autoplace on horizontal surface API.#310

Merged
dli7319 merged 1 commit into
google:mainfrom
dli7319:autoplace
May 28, 2026
Merged

Autoplace on horizontal surface API.#310
dli7319 merged 1 commit into
google:mainfrom
dli7319:autoplace

Conversation

@dli7319
Copy link
Copy Markdown
Collaborator

@dli7319 dli7319 commented May 28, 2026

Adds a xb.world.autoplaceOnHorizontalSurface to place objects on horizontal planes. Updates the modelviewer sample to leverage this API to place each object. Replaces the cylinder in the model viewer sample with an animated torus to be more interesting.

  • Support optional semantic label on simulator planes in SimulatorPlane, DetectedPlane, and SimulatorWorld to allow custom floor/table categorization in emulator scenes.
  • Implement getObjectBoundingBox in HorizontalAutoplacement to exclude ModelViewer interaction handles (platform, rotation mesh) from collision boxes and bounding offsets.
  • Reuse pre-calculated bbox in getObjectBoundingBox to cleanly support Gaussian Splatting models without disappearing offsets.
  • Increase sampling gridSteps to 15 in HorizontalAutoplacement for tighter, high-precision object packing on tables.
  • Register simulated plane meshes inside the PlaneDetector map to allow dynamic targeting and visualization.
  • Swap cylinder mesh with animated, electric-teal TorusKnotGeometry in ModelViewerScene sample.
xrblocks_autoplace_objects_20250527.mp4

@dli7319 dli7319 requested a review from ruofeidu May 28, 2026 00:32
Comment thread samples/modelviewer/main.js Outdated
},
];
options.setAppTitle('Model Viewer');
options.world.enabled = true;
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, I think this is unnecessary. Can I remove it?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean having .enabled on WorldOptions.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure!

I don't think world should be explicitly enabled here --- this is a basic example without virtual / real world interaction.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The placement requires plane tracking.

But I mean world itself doesn't do anything unless you also enable plane tracking or scene meshing so it seems redundant.

Comment thread samples/modelviewer/ModelViewerScene.js Outdated

if (this.placedObjects.has(model)) return;
this.placedObjects.add(model);
const placed = await xb.world.autoplaceOnHorizontalSurface(model, {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

auto sounds redundant here.
it could be placeOnBestSurface ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll remove auto.
I think it's better to keep horizontal in case we want to have placeOnVerticalSurface in the future.

Comment thread src/world/World.ts Outdated
* @param timeout - Optional timeout duration as a Temporal.Duration or Temporal.DurationLike object (defaults to 500ms).
* @returns A promise resolving to true if successfully placed, false otherwise.
*/
async autoplaceOnHorizontalSurface(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

placeOnBestSurface?

Comment thread samples/modelviewer/main.js Outdated
},
];
options.setAppTitle('Model Viewer');
options.world.enabled = true;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure!

I don't think world should be explicitly enabled here --- this is a basic example without virtual / real world interaction.

@ruofeidu ruofeidu self-assigned this May 28, 2026
@ruofeidu ruofeidu added the enhancement New feature or request label May 28, 2026
Adds a `xb.world.autoplaceOnHorizontalSurface` to place objects on horizontal planes.
Updates the modelviewer sample to leverage this API to place each object.
Replaces the cylinder in the model viewer sample with an animated torus to be more interesting.

- Support optional semantic `label` on simulator planes in `SimulatorPlane`, `DetectedPlane`, and `SimulatorWorld` to allow custom floor/table categorization in emulator scenes.
- Implement `getObjectBoundingBox` in `HorizontalAutoplacement` to exclude `ModelViewer` interaction handles (platform, rotation mesh) from collision boxes and bounding offsets.
- Reuse pre-calculated `bbox` in `getObjectBoundingBox` to cleanly support Gaussian Splatting models without disappearing offsets.
- Increase sampling `gridSteps` to 15 in `HorizontalAutoplacement` for tighter, high-precision object packing on tables.
- Register simulated plane meshes inside the `PlaneDetector` map to allow dynamic targeting and visualization.
- Swap cylinder mesh with animated, electric-teal `TorusKnotGeometry` in `ModelViewerScene` sample.
@dli7319 dli7319 merged commit 7193773 into google:main May 28, 2026
8 checks passed
@dli7319 dli7319 deleted the autoplace branch May 28, 2026 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants